export function importModules<T extends object>(modules: T, isDefault = false) {
  let obj: Record<string, any> = {};
  Object.entries(modules).forEach(([key, value]) => {
    if (isDefault) {
      let splits = key.split("/");
      const fileName = splits[splits.length - 1].split(".")[0];
      obj[fileName] = value;
    } else {
      Object.entries(value).forEach(([k, v]) => {
        if (k != "default") {
          obj[k] = v;
        }
      });
    }
  });
  return obj;
}

export default function useTool() {
  return importModules(import.meta.glob("./modules/*.ts", { eager: true }));
}
